package com.team2.insulatingtools.modular.system.controller;

import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import cn.stylefeng.roses.kernel.system.api.pojo.organization.HrOrganizationRequest;
import cn.stylefeng.roses.kernel.system.api.pojo.organization.OrganizationTreeNode;
import com.team2.insulatingtools.modular.system.pojo.request.ToolsHrOrganizationRequest;
import com.team2.insulatingtools.modular.system.service.OrgService;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author yangqian
 * @date 2023-04-05 16:28
 * @description
 **/
@ApiResource(name="绝缘工具组织机构")
@RestController
public class OrgController {

    @Resource
    OrgService organizationService;

    @GetResource(name = "获取组织机构",path = "/sys/getSubOrg")
    public ResponseData getSubOrg(){
        return new SuccessResponseData(organizationService.getSubOrgByCurrent());
    }

    @GetResource(name = "根据角色获取组织机构",path = "/sys/getOrgByRole")
    public ResponseData getOrgByRole(String speciality){
        return new SuccessResponseData(organizationService.getOrgsByRole(speciality));
    }

    @GetResource(
            name = "根据专业获取系统组织机构树",
            path = {"/sys/orgTree"}
    )
    public ResponseData<List<OrganizationTreeNode>> orgTree(ToolsHrOrganizationRequest request) {
        return new SuccessResponseData(organizationService.getTreeBySpeciality(request));
    }

}
